using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;

namespace JH
{
    /// <summary>
    /// 公共的Toggle事件
    /// </summary>
    [RequireComponent(typeof(Toggle))]
    public class CommonToggleEvent : BaseToggleCustomEvent
    {
        /// <summary>
        ///  为真时的事件
        /// </summary>
        [FormerlySerializedAs("onTrue")] [SerializeField, Header("当toggle设置为true时触发")]
        protected UnityEvent onToggleOn;

        /// <summary>
        ///  为假时的事件
        /// </summary>
        [SerializeField, Header("当toggle设置为false时触发")]
        protected UnityEvent onFalse;

        protected override void OnToggleOn()
        {
            base.OnToggleOn();
             onToggleOn?.Invoke();
        }
        
        protected override void OnToggleOff()
        {
            base.OnToggleOff();
            onFalse?.Invoke();
        }
    }
}